package com.gym.chatroom;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;

/**
 * 聊天室的服务器
 * @author admin
 *
 */
@SuppressWarnings("all")
public class Server {
	//所有的客户端线程
	public static HashMap<String, ClientThread> clients = new HashMap<String, ClientThread>();
	public static void main(String[] args) {
		try {
			//创建服务器的监听端口
			ServerSocket serverSocket = new ServerSocket(8888);
			System.err.println("聊天服务器启动，等到用户连接");
			ClientThread clientThread = null;
			//监听
			while(true){
				Socket socket = serverSocket.accept();
				clientThread = new ClientThread(socket);
				clientThread.start();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
